<?
	session_start();//abrir la session del usuario	
	include "../../resources/seguridad/seguridad.php";
	$raizPagina = "../";
	
	require_once "../../resources/bd/db.php";
	include "../../clases/clasificacion.class.php";


	$p = new Clasificacion;
	$tipo = $_REQUEST["tipo"];
	$buscar = $_REQUEST["buscar"];
	if ($buscar != "" && $tipo != "")
	{
		switch ($tipo) 
		{ 
			case 1:
				$arreglo = $p->listarPorNombre($buscar);
			break;			
			case 2:				
				$arreglo = $p->listar();			
			break;
		}
	}
	else
	{
		$arreglo = $p->listar();
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SCA</title>
<style type="text/css">
<!--
.boton{
        font-size:10px;
        font-family:Verdana,Helvetica;
        font-weight:bold;
        color:white;
        background:url(../images/Button.JPG);
        border:0px;
        width:80px;
        height:27px;
 }
.style1 {color: #FFFFFF}
.style4 {
	color: #7BAA0F;
	font-weight: bold;
}
.style5 {
	font-family: Garamond;
	font-weight: bold;
}
-->
</style>
<script type="text/javascript" src="../menu/jquery-1.2.2.pack.js"></script>
<script type="text/javascript" src="../menu/ddaccordion.js">
</script>
<script type="text/javascript">


ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='../menu/plus.gif' class='statusicon' />", "<img src='../menu/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "normal", //speed of animation: "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isclicked){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})


</script>
</head>



<body topmargin="0" bgcolor="#ffffff">
<form name="myForm" action="" method="post">
<table width="800" border="0" align="center" bgcolor="#FFFFFF">
  <tr>
    <td height="71" colspan="2" ><img src="../images/img01.png" width="799" height="84" /></td>
  </tr>
  <tr>
  	<td align="center">
		<table cellpadding="0" cellspacing="0">
		<tr>
    		<td align="center" valign="middle"><img src="../images/Administracion.png" width="112" height="117" />
			<br><span class="style4"><? echo $_SESSION["usuario"]; ?></span></td>
		</tr>
		<tr>
			<td align="left" valign="top"><? include "../menu/menuPrincipal.php"?></td>  
		</tr>
		</table>
	</td>
	<td><!--Panel de Busqueda-->
		<table width="88%" align="center">
			<tr>
				<td width="13%" class="etiqueta style5"><span class="style7">Busca</span>r</td>
				<td width="37%" class="contenido"><input class="contenido" type="text" name="buscar" /></td>
				<td width="7%" class="style7 etiqueta"><span class="style5">Por</span></td>
				<td width="22%" class="contenido"><select class="contenido" name="tipo"><option value="1" selected="selected">Nombre</option><option value="2">Todos</option>
				</select></td>
				<td width="21%" class="contenido"><input type="submit" class="boton" value="Enviar" /></td>
			</tr>			
		</table><!--Fin panel de Busqueda-->
		<br>
		<table width="96%" border="2" align="center" bordercolor="#000033" bgcolor="#FFFFFF">
			<tr>
				<td align="center" ></td>							
				<td align="right" ><input type="button"  class="boton" name="desactivar" value="Eliminar" onclick="javascipt:activar('_desactivar.php','Usted esta seguro de eliminar los clasificacions seleccionadas')"></td>							
			</tr>
			<tr>
				<td align="center" bgcolor="#000000" class="style1 tituloTabla"><input name="checkall" type="checkbox" id="checkall" value="checkall" onClick="checkAll();" /></td>
				<td align="center" bgcolor="#000000" class="tituloTabla style1"><strong>Clasificacion</strong></td>
			</tr>
			<?
				$max = count($arreglo["id_clasificacion"]);
				for($i=0; $i<$max; ++$i) 
			   { 
				 $id = $arreglo["id_clasificacion"][$i];
				 printf("<tr><td align='center'><input type='checkbox' name='".$id."' id='".$id."' value='".$id."' ></td>");		   	 				   	
				 printf("<td class='contenido'align='left'><a href='modClasificacion.php?id_clasificacion=".$id."' >".$arreglo["nombre_clasificacion"][$i]."</a></td>");				
				 printf("</tr>");					
			   }
			?>
		</table>		
	</td>
  </tr>
  <tr>
    <td height="86" colspan="2"><img src="../images/img09.png" width="799" height="84" /></td>
  </tr>   
</table>
<input type="hidden" name="codigos" />
</form>
<script language="javascript">

function checkAll() {

	var nodoCheck = document.getElementsByTagName("input");

	var varCheck = document.getElementById("checkall").checked;

	for (i=0; i<nodoCheck.length; i++){

		if (nodoCheck[i].type == "checkbox" && nodoCheck[i].name != "docentes" && nodoCheck[i].disabled == false) {

			nodoCheck[i].checked = varCheck;

		}

	}

}


function activar(pag,msj)
{

	var nodoCheck = document.getElementsByTagName("input");

	var cont = 0;

	if(nodoCheck.length>0)

	{

		for (i=0; i<nodoCheck.length; i++)

		{

			if ((nodoCheck[i].type == "checkbox")&&(nodoCheck[i].disabled == false))

			{				

				if (nodoCheck[i].checked)

				{

					cont++;

					if (i == 0)

					{

						document.myForm.codigos.value = nodoCheck[i].value;

					}

					else

					{

						document.myForm.codigos.value = document.myForm.codigos.value + "," + nodoCheck[i].value;

					}

				}

			}

		}

	}

	if (cont != 0)

	{

		if (confirm(msj))

		{

			document.myForm.action = pag;

			document.myForm.submit();

		}

	}

	else

	{

		alert('Seleccione un clasificacion');

	}

}

</script>

</body>

</html>
